package com.anolesoft.yr.mbus.contm.service.impl;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.anolesoft.yr.mbus.contm.entity.ContmBaseClauseExample;
import com.anolesoft.yr.mbus.contm.dao.ContmBaseClauseDao;
import com.anolesoft.yr.mbus.contm.entity.ContmBaseClause;
import com.anolesoft.yr.mbus.contm.service.ContmBaseClauseService;
@Service
public class ContmBaseClauseServiceImpl extends ServiceImpl<ContmBaseClauseDao, ContmBaseClause> implements ContmBaseClauseService{

    @Override
    public long countByExample(ContmBaseClauseExample example) {
        return baseMapper.countByExample(example);
    }
    @Override
    public int deleteByExample(ContmBaseClauseExample example) {
        return baseMapper.deleteByExample(example);
    }
    @Override
    public List<ContmBaseClause> selectByExample(ContmBaseClauseExample example) {
        return baseMapper.selectByExample(example);
    }
    @Override
    public int updateByExampleSelective(ContmBaseClause record,ContmBaseClauseExample example) {
        return baseMapper.updateByExampleSelective(record,example);
    }
    @Override
    public int updateByExample(ContmBaseClause record,ContmBaseClauseExample example) {
        return baseMapper.updateByExample(record,example);
    }
    @Override
    public int updateBatch(List<ContmBaseClause> list) {
        return baseMapper.updateBatch(list);
    }
    @Override
    public int updateBatchSelective(List<ContmBaseClause> list) {
        return baseMapper.updateBatchSelective(list);
    }
    @Override
    public int batchInsert(List<ContmBaseClause> list) {
        return baseMapper.batchInsert(list);
    }
    @Override
    public int insertOrUpdate(ContmBaseClause record) {
        return baseMapper.insertOrUpdate(record);
    }
    @Override
    public int insertOrUpdateSelective(ContmBaseClause record) {
        return baseMapper.insertOrUpdateSelective(record);
    }


    public void pageInsertBatch(List<ContmBaseClause> contmBaseClauses){
        for (int i = 0; i < contmBaseClauses.size(); i++) {

            if ( contmBaseClauses.get(i)!=null&&contmBaseClauses.get(i).getContmBaseClauses()!=null)
            {
                saveExecute(contmBaseClauses.get(i), contmBaseClauses.get(i).getPageType());
            }
        }
        
    }
    
    private void saveExecute(ContmBaseClause contmBaseClause,String pageType){
        contmBaseClause.setPageType(pageType);
        save(contmBaseClause);
        if (contmBaseClause.getContmBaseClauses()!=null){
            contmBaseClause.getContmBaseClauses().forEach(a->{
                saveExecute(a,pageType);
            });
        }
    }

}
